package com.struts.deal.corpor.register;

import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.base.Constants;
import com.ibatis.po.corpor.TCorporation;
import com.ibatis.po.corpor.TKindofcorporation;
import com.ibatis.po.system.TCiyt;
import com.ibatis.po.user.TUserInfo;
import com.ibatis.po.user.TVocation;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CSqlMap;
import com.lg.system.Common;
import com.lg.system.MessageBean;
import com.struts.web.corpor.manage.infomanage.EditInfoForm;
import com.struts.web.corpor.register.CorporBaseForm;
import com.struts.web.corpor.register.CorporDetailForm;
import com.struts.web.user.register.RegFinishForm;

//poi技术
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.awt.font.NumericShaper;
import java.io.FileInputStream;

public class Deal {

	/**
	 * 添加企业基本信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean addBase(HttpServletRequest request,
			HttpServletResponse response, CorporBaseForm aWebForm)
			throws SQLException {
		boolean result = false;
		TCorporation corpor = new TCorporation();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig(); 

		corpor.setId(Common.getNewID());
		corpor.setLoginName(aWebForm.getLoginName().trim());
		corpor.setPassWord(aWebForm.getPassword().trim());
		corpor.setContactAddress(aWebForm.getContactAddress());
		corpor.setContactPerson(aWebForm.getContactPerson().trim());
		corpor.setCorporationName(aWebForm.getCorporName().trim());
		corpor.setTelephone(aWebForm.getTelephone().trim());
		corpor.setMobilphone(aWebForm.getMobilphone().trim());
		corpor.setEmail(aWebForm.getEmail().trim());
		corpor.setRegistDate(new java.sql.Timestamp(new java.util.Date()
				.getTime()));
		corpor.setIsrecommend("0");
		try {
			sqlmap.insert("T_CORPORATION.abatorgenerated_insert", corpor);
			request.getSession().setAttribute("Corporation", corpor);
			result = true;
		} catch (Exception e) {
			e.printStackTrace();
		}

		return result;

	}

	/**
	 * 添加企业详细信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean addDetail(HttpServletRequest request,
			HttpServletResponse response, CorporDetailForm aWebForm)
			throws SQLException {
		boolean result = false;
		TCorporation corpor = (TCorporation) request.getSession().getAttribute(
				"Corporation");
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		try {
			if (corpor != null) {
				TCorporation corpor1 = new TCorporation();
				corpor1.setId(corpor.getId());
				corpor1.setVocationId(aWebForm.getVocation());
				corpor1.setKindId(aWebForm.getKind());
				corpor1.setAddress(aWebForm.getAddress());

				if (aWebForm.getCreateDate() != null
						&& aWebForm.getCreateDate() != "") {
					java.util.Date dcreateDate = df.parse(aWebForm
							.getCreateDate());
					java.sql.Timestamp createDate = new java.sql.Timestamp(
							dcreateDate.getTime());
					corpor1.setCreateDate(createDate);
				}

				corpor1.setHomepage(aWebForm.getHomepage());
				corpor1.setCorporationSynopsis(request
						.getParameter("corporationSynopsis"));
				sqlmap
						.update(
								"T_CORPORATION.abatorgenerated_updateByPrimaryKeySelective",
								corpor1);
				result = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return result;

	}

	/**
	 * 管理员添加企业
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean addCorpor(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		TCorporation corpor = new TCorporation();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		try {
			TCorporation corpor1 = new TCorporation();
			corpor.setLoginName(aWebForm.getCorporPo().getLoginName());
			int count = 0;
			System.out.println(aWebForm.getCorporPo().getCorporationName());
			count = ((Integer) sqlmap.queryForObject(
					"T_CORPORATION.selectCount", corpor)).intValue();
			if (count > 0) {
				System.out.println(count);
				messageBean.setMessage(Constants.USER_EXIST);
				return messageBean;
			}

			corpor1.setId(Common.getNewID());//编号
			corpor1.setLoginName(aWebForm.getCorporPo().getLoginName());//登录名
			corpor1.setCorporationName(aWebForm.getCorporPo()
					.getCorporationName());//企业名称
			corpor1.setContactPerson(aWebForm.getCorporPo().getContactPerson());//联系人
			corpor1.setTelephone(aWebForm.getCorporPo().getTelephone());//电话号码
			corpor1.setMobilphone(aWebForm.getCorporPo().getMobilphone());//手机号码
			corpor1.setEmail(aWebForm.getCorporPo().getEmail());//邮箱
			corpor1.setStatus("1");
			System.out.println(corpor1.getStatus());
			corpor1.setContactAddress(aWebForm.getCorporPo()
					.getContactAddress());//联系地址
			corpor1.setPassWord(aWebForm.getCorporPo().getPassWord());//密码
			corpor1.setVocationId(aWebForm.getCorporPo().getVocationId());//行业编号
			corpor1.setKindId(aWebForm.getCorporPo().getKindId());//类型编号
			corpor1.setAddress(aWebForm.getCorporPo().getAddress());//地址

			if (aWebForm.getCorporPo().getCreateDate() != null
					&& aWebForm.getCorporPo().getCreateDate() != "") {
				java.util.Date dcreateDate = df.parse(aWebForm.getCorporPo()
						.getCreateDate());
				java.sql.Timestamp createDate = new java.sql.Timestamp(
						dcreateDate.getTime());
				corpor1.setCreateDate(createDate);//创立时间
			}

			corpor1.setHomepage(aWebForm.getCorporPo().getHomepage());//主页
			corpor1.setCorporationSynopsis(request
					.getParameter("corporContent"));//简历

			sqlmap.insert("T_CORPORATION.addcorpor", corpor1);
			messageBean.setResult(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return messageBean;

	}

	/**
	 * 导入企业信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean importCorpor(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();

		try {
			String xlsFile = "c:\\doc\\corpor.xls";
			POIFSFileSystem fIn = new POIFSFileSystem(new FileInputStream(
					xlsFile));
			HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
			HSSFSheet readSheet = readWorkBook.getSheet("企业联系信息");
			HSSFRow readRow;
			HSSFCell readCell;
			int rowNum = readSheet.getLastRowNum();

			for (int i = 1; i <= rowNum; i++) {

				readRow = readSheet.getRow(i);
				readCell = readRow.getCell((short) 2);
				readCell.setCellType(HSSFCell.CELL_TYPE_STRING);
				TCorporation corpor1 = new TCorporation();
				corpor1.setId(Common.getNewID());//编号
				corpor1.setCorporationName(readCell.getStringCellValue());//企业名称
				int count = 0;
				count = ((Integer)sqlmap.queryForObject("T_CORPORATION.selectCount",corpor1)).intValue();
				if(count>0){
					continue;
				}
				readCell = readRow.getCell((short) 3);
				corpor1.setTelephone(nullToString(readCell));//电话号码

				readCell = readRow.getCell((short) 4);
				corpor1.setFax(nullToString(readCell));//传真

				readCell = readRow.getCell((short) 5);
				corpor1.setContactPerson(nullToString(readCell));//联系人

				readCell = readRow.getCell((short) 6);
				corpor1.setContactAddress(nullToString(readCell));//联系地址

				corpor1.setStatus("1");

				corpor1.setCorporationSynopsis("简历");//简历

				sqlmap.insert("T_CORPORATION.importCorpor", corpor1);
			}
			messageBean.setResult(true);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return messageBean;

	}

	/**
	 * 导入黑名单企业
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean importBlack(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		TCorporation corpor = new TCorporation();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		try {
			String xlsFile = "c:\\doc\\corpor.xls";
			POIFSFileSystem fIn = new POIFSFileSystem(new FileInputStream(
					xlsFile));
			HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
			HSSFSheet readSheet = readWorkBook.getSheet("企业联系信息");
			HSSFRow readRow;
			HSSFCell readCell;
			int rowNum = readSheet.getLastRowNum();

			for (int i = 1; i <= rowNum; i++) {
				readRow = readSheet.getRow(i);
				readCell = readRow.getCell((short) 2);
				readCell.setCellType(HSSFCell.CELL_TYPE_STRING);

				TCorporation corpor1 = new TCorporation();
				corpor.setCorporationName(readCell.getStringCellValue());
				int count = 0;
				count = ((Integer) sqlmap.queryForObject(
						"T_CORPORATION.selectCountByName", corpor)).intValue();
				if (count > 0) {
					continue;
				}

				corpor1.setId(Common.getNewID());//编号
				corpor1.setCorporationName(readCell.getStringCellValue());//企业名称

				readCell = readRow.getCell((short) 3);
				corpor1.setTelephone(nullToString(readCell));//电话号码

				readCell = readRow.getCell((short) 4);
				corpor1.setFax(nullToString(readCell));//传真

				readCell = readRow.getCell((short) 5);
				corpor1.setContactPerson(nullToString(readCell));//联系人

				readCell = readRow.getCell((short) 6);
				corpor1.setContactAddress(nullToString(readCell));//联系地址

				corpor1.setStatus("1");

				corpor1.setCorporationSynopsis("简历");//简历

				sqlmap.insert("T_CORPORATION.importCorpor", corpor1);
			}
			messageBean.setResult(true);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return messageBean;

	}

	/**
	 * 导入求职者
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean importUser(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		TUserInfo userPo = new TUserInfo();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();

		try {
			String xlsFile = "c:\\doc\\user.xls";
			POIFSFileSystem fIn = new POIFSFileSystem(new FileInputStream(
					xlsFile));
			HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
			HSSFSheet readSheet = readWorkBook.getSheet("求职者登记");
			HSSFRow readRow;
			HSSFCell readCell;
			int rowNum = readSheet.getLastRowNum();

			for (int i = 2; i <= rowNum; i++) {
				readRow = readSheet.getRow(i);

				userPo.setId(Common.getNewID());

				readCell = readRow.getCell((short) 1);
				userPo.setName(nullToString(readCell));//用户姓名

				readCell = readRow.getCell((short) 2);
				userPo.setSex(nullToString(readCell).trim());//性别

				readCell = readRow.getCell((short) 6);
				userPo.setMobilphone(nullToString(readCell));//手机号码

				readCell = readRow.getCell((short) 8);
				userPo.setFavoriteJob(nullToString(readCell));//职位要求

				sqlmap.insert("T_USER_INFO.importUser", userPo);
			}
			messageBean.setResult(true);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return messageBean;

	}

	public static String nullToString(HSSFCell cell) throws Exception {
		String str;
		if (cell == null) {
			str = "无";
		} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
			System.out.println("num:" + cell.getNumericCellValue());
			str = Double.toString(cell.getNumericCellValue());
			System.out.println("String:" + str);
		} else {
			str = cell.getStringCellValue();
		}

		return str;
	}

	public static String nullToString(NumericShaper str) throws Exception {

		if (str == null) {
			//str = "12345678";
		}
		return null;
	}

	/**
	 * 加载企业详细信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static void loadDetail(HttpServletRequest request,
			HttpServletResponse response, CorporDetailForm aWebForm)
			throws SQLException {

		List cityList = null;
		List vocationList = null;
		List kindList = null;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCiyt cityPo = new TCiyt();
		TVocation vocationPo = new TVocation();
		TKindofcorporation kindPo = new TKindofcorporation();
		String str = "";
		String str2 = "";
		String str3 = "";
		String sKey = "";
		String sValue = "";

		try {
			//企业性质
			str += "var kindId=new Array('','－－请选择性质－－'";
			kindList = sqlmap
					.queryForList("T_KINDOFCORPORATION.abatorgenerated_selectByExample");
			for (int i = 0; i < kindList.size(); i++) {
				kindPo = (TKindofcorporation) kindList.get(i);
				sKey = kindPo.getId();
				sValue = kindPo.getKindOfName();
				str += ",'" + sKey + "',";
				str += "'" + sValue + "'\n";
			}
			str += ");\n";

			//行业列表
			str2 += "var vocation=new Array('','－－请选择行业－－'";
			vocationList = sqlmap.queryForList("T_VOCATION.selectAll");
			for (int i = 0; i < vocationList.size(); i++) {
				vocationPo = (TVocation) vocationList.get(i);
				sKey = vocationPo.getId();
				sValue = vocationPo.getVocationName();
				str2 += ",'" + sKey + "',";
				str2 += "'" + sValue + "'\n";
			}
			str2 += ");\n";

			//地区列表
			str3 += "var address=new Array('','－－请选择地区－－'";
			cityList = sqlmap.queryForList("T_CIYT.selectAllCity");
			for (int i = 0; i < cityList.size(); i++) {
				cityPo = (TCiyt) cityList.get(i);
				sKey = cityPo.getId();
				sValue = cityPo.getCityName();
				if ((Integer.parseInt(sKey) % 100) == 0) {
					str3 += ",'" + sKey + "',";
					str3 += "'" + sValue + "'\n";
				} else {
					str3 += ",'" + sKey + "',";
					str3 += "'&nbsp;&nbsp;&nbsp;&nbsp;" + sValue + "'\n";
				}
			}
			str3 += ");\n";
			aWebForm.setPrintKindSql(str);
			aWebForm.setPrintVacaSql(str2);
			aWebForm.setPrintAddressSql(str3);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * 管理员加载企业详细信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static void loadAddCorpor(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {

		List cityList = null;
		List vocationList = null;
		List kindList = null;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCiyt cityPo = new TCiyt();
		TVocation vocationPo = new TVocation();
		TKindofcorporation kindPo = new TKindofcorporation();
		String str = "";
		String str2 = "";
		String str3 = "";
		String sKey = "";
		String sValue = "";

		try {
			//企业性质
			str += "var kindId=new Array('','－－请选择性质－－'";
			kindList = sqlmap
					.queryForList("T_KINDOFCORPORATION.abatorgenerated_selectByExample");
			for (int i = 0; i < kindList.size(); i++) {
				kindPo = (TKindofcorporation) kindList.get(i);
				sKey = kindPo.getId();
				sValue = kindPo.getKindOfName();
				str += ",'" + sKey + "',";
				str += "'" + sValue + "'\n";
			}
			str += ");\n";

			//行业列表
			str2 += "var vocation=new Array('','－－请选择行业－－'";
			vocationList = sqlmap.queryForList("T_VOCATION.selectAll");
			for (int i = 0; i < vocationList.size(); i++) {
				vocationPo = (TVocation) vocationList.get(i);
				sKey = vocationPo.getId();
				sValue = vocationPo.getVocationName();
				str2 += ",'" + sKey + "',";
				str2 += "'" + sValue + "'\n";
			}
			str2 += ");\n";

			//地区列表
			str3 += "var address=new Array('','－－请选择地区－－'";
			cityList = sqlmap.queryForList("T_CIYT.selectAllCity");
			for (int i = 0; i < cityList.size(); i++) {
				cityPo = (TCiyt) cityList.get(i);
				sKey = cityPo.getId();
				sValue = cityPo.getCityName();
				if ((Integer.parseInt(sKey) % 100) == 0) {
					str3 += ",'" + sKey + "',";
					str3 += "'" + sValue + "'\n";
				} else {
					str3 += ",'" + sKey + "',";
					str3 += "'&nbsp;&nbsp;&nbsp;&nbsp;" + sValue + "'\n";
				}
			}
			str3 += ");\n";
			aWebForm.setPrintKindSql(str);
			aWebForm.setPrintVacaSql(str2);
			aWebForm.setPrintAddressSql(str3);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * 注册完成
	 * @param request
	 * @param response
	 * @param aWebForm
	 */
	public static void doFinish(HttpServletRequest request,
			HttpServletResponse response, RegFinishForm aWebForm) {

		TCorporation corpor = (TCorporation) request.getSession().getAttribute(
				"Corporation");
		if (corpor != null) {
			aWebForm.setLoginName(corpor.getLoginName());
			aWebForm.setPassWord(corpor.getPassWord());
			corpor.setPassWord("");
			request.getSession().setAttribute("Corporation", corpor);
		}
	}

	/**
	 * 加载企业信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean loadInfo(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor = new TCorporation();
		MessageBean messageBean = new MessageBean();
		corpor.setId(request.getParameter("corporId"));

		String str = "";
		String str2 = "";
		String str3 = "";
		String sKey = "";
		String sValue = "";
		List cityList = null;
		List vocationList = null;
		List kindList = null;
		TCiyt cityPo = new TCiyt();
		TVocation vocationPo = new TVocation();
		TKindofcorporation kindPo = new TKindofcorporation();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		try {
			if (corpor.getId() != null && corpor.getId() != "") {
				corpor = (TCorporation) sqlmap.queryForObject(
						"T_CORPORATION.abatorgenerated_selectByPrimaryKey",
						corpor);
				aWebForm.getCorporPo().setContactPerson(
						corpor.getContactPerson());//联系人
				aWebForm.getCorporPo().setContactAddress(
						corpor.getContactAddress());//联系地址
				aWebForm.getCorporPo().setHomepage(corpor.getHomepage());//主页
				aWebForm.getCorporPo().setCorporationName(
						corpor.getCorporationName());//企业名称
				aWebForm.getCorporPo().setCorporationSynopsis(
						corpor.getCorporationSynopsis());//简历
				aWebForm.getCorporPo().setEmail(corpor.getEmail());//邮箱
				aWebForm.getCorporPo().setMobilphone(corpor.getMobilphone());//手机
				aWebForm.getCorporPo().setTelephone(corpor.getTelephone());//联系电话
				aWebForm.getCorporPo().setOthers(corpor.getOthers());
				aWebForm.getCorporPo().setRegNumber(corpor.getRegNumber());
				if (corpor.getCreateDate() != null) {
					aWebForm.getCorporPo().setCreateDate(
							format.format(corpor.getCreateDate()));//创建日期
				}
				if (corpor.getLimitDate() != null) {
					aWebForm.getCorporPo().setLimitDate(
							format.format(corpor.getLimitDate()));
				}
				aWebForm.getCorporPo().setLoginName(corpor.getLoginName());//登录名
				request.setAttribute("kind", corpor.getKindId());
				request.setAttribute("vocat", corpor.getVocationId());
				request.setAttribute("addr", corpor.getAddress());

				//企业性质
				str += "var kindId=new Array('','－－请选择性质－－'";
				kindList = sqlmap
						.queryForList("T_KINDOFCORPORATION.abatorgenerated_selectByExample");
				for (int i = 0; i < kindList.size(); i++) {
					kindPo = (TKindofcorporation) kindList.get(i);
					sKey = kindPo.getId();
					sValue = kindPo.getKindOfName();
					str += ",'" + sKey + "',";
					str += "'" + sValue + "'\n";
				}
				str += ");\n";

				//行业列表
				str2 += "var vocation=new Array('','－－请选择行业－－'";
				vocationList = sqlmap.queryForList("T_VOCATION.selectAll");
				for (int i = 0; i < vocationList.size(); i++) {
					vocationPo = (TVocation) vocationList.get(i);
					sKey = vocationPo.getId();
					sValue = vocationPo.getVocationName();
					str2 += ",'" + sKey + "',";
					str2 += "'" + sValue + "'\n";
				}
				str2 += ");\n";

				//地区列表
				str3 += "var address=new Array('','－－请选择地区－－'";
				cityList = sqlmap.queryForList("T_CIYT.selectAllCity");
				for (int i = 0; i < cityList.size(); i++) {
					cityPo = (TCiyt) cityList.get(i);
					sKey = cityPo.getId();
					sValue = cityPo.getCityName();
					if ((Integer.parseInt(sKey) % 100) == 0) {
						str3 += ",'" + sKey + "',";
						str3 += "'" + sValue + "'\n";
					} else {
						str3 += ",'" + sKey + "',";
						str3 += "'&nbsp;&nbsp;&nbsp;&nbsp;" + sValue + "'\n";
					}
				}
				str3 += ");\n";

				aWebForm.setPrintAddressSql(str3);
				aWebForm.setPrintKindSql(str);
				aWebForm.setPrintVacaSql(str2);
				messageBean.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return messageBean;
	}

	/**
	 * 企业信息修改
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean editInfo(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		String corporId = aWebForm.getCorporPo().getId();
		TCorporation corpor1 = new TCorporation();
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		try {
			if (corporId != null && corporId != "") {

				corpor1.setId(corporId);//编号
				corpor1.setContactAddress(aWebForm.getCorporPo()
						.getContactAddress());//联系地址
				corpor1.setContactPerson(aWebForm.getCorporPo()
						.getContactPerson());//联系人
				corpor1.setCorporationName(aWebForm.getCorporPo()
						.getCorporationName());//企业名称
				corpor1.setCorporationSynopsis(request
						.getParameter("corporContent"));//简历

				if (aWebForm.getCorporPo().getCreateDate() != null
						&& aWebForm.getCorporPo().getCreateDate() != "") {
					java.util.Date mcreateDate = df.parse(aWebForm
							.getCorporPo().getCreateDate());
					java.sql.Timestamp createDate = new java.sql.Timestamp(
							mcreateDate.getTime());
					corpor1.setCreateDate(createDate);//创建日期
				}
				if (aWebForm.getCorporPo().getLimitDate() != null
						&& aWebForm.getCorporPo().getLimitDate() != "") {
					java.util.Date mcreateDate = df.parse(aWebForm
							.getCorporPo().getLimitDate());
					java.sql.Timestamp createDate = new java.sql.Timestamp(
							mcreateDate.getTime());
					corpor1.setLimitDate(createDate);
				}
				corpor1.setLoginName(aWebForm.getCorporPo().getLoginName());//登录名

				corpor1.setAddress(aWebForm.getCorporPo().getAddress());//地址
				corpor1.setEmail(aWebForm.getCorporPo().getEmail());//邮箱
				corpor1.setTelephone(aWebForm.getCorporPo().getTelephone());//联系电话
				
				if(aWebForm.getCorporPo().getPassWord()!=null && aWebForm.getCorporPo().getPassWord()!=""){
				corpor1.setPassWord(aWebForm.getCorporPo().getPassWord());//密码
				}
				corpor1.setMobilphone(aWebForm.getCorporPo().getMobilphone());//手机
				corpor1.setHomepage(aWebForm.getCorporPo().getHomepage());//主页
				corpor1.setKindId(aWebForm.getCorporPo().getKindId());//类别
				corpor1.setVocationId(aWebForm.getCorporPo().getVocationId());//行业
				corpor1.setOthers(aWebForm.getCorporPo().getOthers());
				corpor1.setRegNumber(aWebForm.getCorporPo().getRegNumber());

				sqlmap
						.update(
								"T_CORPORATION.abatorgenerated_updateByPrimaryKeySelective",
								corpor1);
				messageBean.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return messageBean;
	}

	/**
	 * 删除企业
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean delCorpor(HttpServletRequest request,
			HttpServletResponse response, EditInfoForm aWebForm)
			throws SQLException {
		MessageBean messageBean = new MessageBean();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor = new TCorporation();
		String corporId = aWebForm.getCorporPo().getId();
		try {
			if (corporId != null && corporId != "") {
				corpor.setId(corporId);
				sqlmap
						.queryForObject("F_DEL_TABLE.delAllAboutCorpor",
								corporId);
				messageBean.setResult(true);
			}
		} catch (Exception e) {
			messageBean.setMessage(Constants.DEL_FAIL);
			e.printStackTrace();
		}
		return messageBean;
	}
}
